/*
 * File:   ServerSocket.hpp
 * Author: samcrow
 *
 * Created on March 14, 2012, 6:01 PM
 */

#ifndef SERVERSOCKET_HPP
#define	SERVERSOCKET_HPP

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <stdlib.h>
#include <errno.h>
#include <iostream>
#include <string.h>
#include <string>

class ServerSocket {
public:
	/**
	 * Construct the socket to listen on a given port.
	 * This function blocks until a client connects to it.
     * @param port The port number to listen on
     */
	ServerSocket(int port);

	/**
	 * Send data over the socket connection
     * @param text The text to send
     * @return The number of bytes that were sent
     */
	int send(std::string text);

	virtual ~ServerSocket();
private:
	/** The socket identifier to write to */
	int m_socket;
};

#endif	/* SERVERSOCKET_HPP */

